package com.cy.model;

import com.cy.BasicModel;
import com.cy.ext.plugin.tablebind.TableBind;
import com.jfinal.plugin.activerecord.Db;

import static com.cy.utils.SimpleSqlUtils.in;

@TableBind(tableName="permission")
public class Permission extends BasicModel<Permission> {
    public static final Permission dao = new Permission();
    public static final String SELECT_ALL = "`account_role_id`,`menu_id`";


    public void deleteByRoleAndMenu(Object[] roleIds, Object[] menuIds) {
        Db.update("DELETE FROM permission WHERE "+ in("account_role_id", roleIds) +" AND "+ in("menu_id", menuIds));
    }

    public Permission setAccountRoleId(Long accountRoleId){
        return this.set("account_role_id",accountRoleId);
    }

    public Long getAccountRoleId(){
        return this.get("account_role_id");
    }
        
    public Permission setMenuId(Long menuId){
        return this.set("menu_id",menuId);
    }

    public Long getMenuId(){
        return this.get("menu_id");
    }
}
